package org.tio.sitexxx.im.common;

import org.lionsoul.ip2region.DataBlock;
import org.tio.sitexxx.im.common.bs.HandshakeReq;
import org.tio.websocket.common.WsSessionContext;

/**
 *
 * @author tanyaowu
 *
 */
public class ImSessionContext {

	/**
	 * 握手时的用户id，注意：就算后来被踢了，此值仍然不会被清空，可用于数据统计，但不能用此值来获取当前用户
	 */
	private Integer uid;

	private boolean isWebsocket = false;

	/**
	 * 当前Channel所在的groupid
	 */
	private String groupid;

	/**
	 * 是否已经握过手
	 */
	private boolean isHandshaked = false;

	private boolean isSupper = false;

	/**
	 * 上一次发群聊消息的时间
	 */
	private long lastGroupChatTime = 0;

	private HandshakeReq handshakeReq;

	/**
	 * 如果是ws，则有此对象
	 */
	private WsSessionContext wsSessionContext;

	/**
	 * ip地址信息
	 */
	private DataBlock dataBlock;

	public boolean isHandshaked() {
		return isHandshaked;
	}

	public void setHandshaked(boolean isHandshaked) {
		this.isHandshaked = isHandshaked;
	}

	public DataBlock getDataBlock() {
		return dataBlock;
	}

	public void setDataBlock(DataBlock dataBlock) {
		this.dataBlock = dataBlock;
	}

	/**
	 * @return the wsSessionContext
	 */
	public WsSessionContext getWsSessionContext() {
		return wsSessionContext;
	}

	/**
	 * @param wsSessionContext the wsSessionContext to set
	 */
	public void setWsSessionContext(WsSessionContext wsSessionContext) {
		this.wsSessionContext = wsSessionContext;
	}

	/**
	 * @return the handshakeReq
	 */
	public HandshakeReq getHandshakeReq() {
		return handshakeReq;
	}

	/**
	 * @param handshakeReq the handshakeReq to set
	 */
	public void setHandshakeReq(HandshakeReq handshakeReq) {
		this.handshakeReq = handshakeReq;
	}

	/**
	 * 握手时的用户id，注意：就算后来被踢了，此值仍然不会被清空，可用于数据统计，但不能用此值来获取当前用户
	 * @return
	 * @author: tanyaowu
	 */
	public Integer getUid() {
		return uid;
	}

	/**
	 * 握手时的用户id，注意：就算后来被踢了，此值仍然不会被清空，可用于数据统计，但不能用此值来获取当前用户
	 * @param uid
	 * @author: tanyaowu
	 */
	public void setUid(Integer uid) {
		this.uid = uid;
	}

	public long getLastGroupChatTime() {
		return lastGroupChatTime;
	}

	public void setLastGroupChatTime(long lastGroupChatTime) {
		this.lastGroupChatTime = lastGroupChatTime;
	}

	public boolean isSupper() {
		return isSupper;
	}

	public void setSupper(boolean isSupper) {
		this.isSupper = isSupper;
	}

	/**
	 * @return the groupid
	 */
	public String getGroupid() {
		return groupid;
	}

	/**
	 * @param groupid the groupid to set
	 */
	public void setGroupid(String groupid) {
		this.groupid = groupid;
	}

	public boolean isWebsocket() {
		return isWebsocket;
	}

	public void setWebsocket(boolean isWebsocket) {
		this.isWebsocket = isWebsocket;
	}
}
